#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <string.h>

int Fact(int n)
{
	if(n==0) 	return 1;
	else 		return n*Fact(n-1);
}
int main(void)
{
	{
		const int m=2;
		int	arr[m];
		const int * const p = &m;
		assert(p!=NULL);	
	}	
	{
		int a=10;
		int b=20;
		printf("1:a=%d b=%d\n",a,b);
		a=a^b;
		b=a^b;
		a=a^b;
		printf("2:a=%d b=%d\n",a,b);
	}
	{
		int a=0;
		int count=0;
		printf("please input a num and return the amount of 1\n");
		scanf("%d",&a);
		while(a)
		{
			a&=(a-1);
			count++;
		}
		printf("%d\n",count);
	}
	{
		srand((unsigned int)time(NULL));
		for(int i=0;i<8;i++)
		{
			printf("0%d %d\n",i,rand());
		}
	}
	{
		char arr1[]="Welcome to the C word!";
		char arr2[]="**********************";
		int left=0;
		int right=strlen(arr1)-1;
		while(left<=right)
		{
			arr2[left]=arr1[left];
			arr2[right]=arr1[right];
			left++;
			right--;
			printf("%s",arr2);
			Sleep(500);		//before
			system("cls");	
			
		}		
	}
	{
		int num=0;
		printf("please input a num and return the num!\n");
		scanf("%d",&num);
		printf("%d\n",Fact(num));	
	}
	/*
	{
		system("shutdown -s -t 120");
		char input[20]=" ";
	next:
		printf("your computer will shutdown in 120s,please input A to cancel it!\n");
		scanf("%s",input);
		if(strcmp("A",input)==0)
		{
			system("shutdown -a");
		}
		else goto next;
	}
	*/
	return 0;
}